﻿@model FairyWorld.Models.User

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/UserLayout.cshtml";
}

<script type="text/ecmascript">
    $(document).ready(function () {
        $("#indexli").attr("class", "active");
    })

    function checkGroupName() {
        if ($("#name").val() != "") {
            window.location.href = "/User/AddGroup?name=" + $("#name").val();
        }else{
            $.globalMessenger().post({
                message: '输入的组名为空！请输入组名',
                type: 'error',
                showCloseButton: true
            });
        }
    }
</script>
<style type="text/css">
	    .wrapper{ 
	    width:930px; 
	    background-color:#fff; 
	    position:relative;	    
	    box-shadow:1px 1px 4px rgba(0,0,0,0.4); 
	    -moz-box-shadow:1px 1px 4px rgba(0,0,0,0.4);
        -webkit-box-shadow: 1px 1px 4px rgba(0,0,0,.4);
        padding:20px;
	    }
 </style>
<h3>团队</h3>
<div class="wrapper">
<table class="table table-hover">
    <tr>
        <th class="span1"></th>
        <th class="span3">组名</th>
        <th class="span3">删除/退出</th>
    </tr>
    @foreach (var role in Model.roles)
    {
        <tr>
            <td><img src="../../Content/image/icon/group1.png" style="width:30px"/></td>
            <td><a href="/Group?id=@role.group.GroupId">@role.group.groupname</a></td>
            <td>
                @if (role.group.creator.UserId == ViewBag.User.UserId)
                {
                    @Html.ActionLink("删除", "DeleteGroup", new { id = role.group.GroupId })
                }
                else
                {
                    @Html.ActionLink("退出", "LeaveGroup", new { id = role.group.GroupId })
                }
            </td>
        </tr>
    }
</table>

    <div class="input-append" style="margin-top:10px">
        <input id="name" name="name" type="text" placeholder="组名">
        <input type="button" onclick="checkGroupName()" class="btn" value="新建组"/>
    </div>

</div>